/** Interactive Surface  FYP- 25 Interactive Surface FYP- 25 Interactive Surface FYP- 25
 *
 *  @author Acer
 */
package test.shanika;

import com.googlecode.javacv.cpp.opencv_core.CvMat;
import com.googlecode.javacv.cpp.opencv_core.CvPoint;
import com.googlecode.javacv.cpp.opencv_video;
import com.googlecode.javacv.cpp.opencv_video.*;

/** Interactive Surface FYP- 25 Interactive Surface FYP- 25 Interactive Surface FYP- 25
 *  General Information about this class -
 *  Comments -
 */
public class KalmanSha {

    CvKalman filter1 = CvKalman.create(4, 2, 0);
    //cvCreateKalman(4, 2, 0);

    {
        CvPoint point = CvPoint.ZERO;
        CvMat gh = CvMat.create(4, 4);


        gh.put(0, 0, 1);
        gh.put(0, 1, 0);
        gh.put(0, 2, 1);
        gh.put(0, 3, 0);

        gh.put(1, 0, 0);
        gh.put(1, 1, 1);
        gh.put(1, 2, 0);
        gh.put(1, 3, 1);

        gh.put(2, 0, 0);
        gh.put(2, 1, 0);
        gh.put(2, 2, 1);
        gh.put(2, 3, 0);

        gh.put(3, 0, 0);
        gh.put(3, 1, 0);
        gh.put(3, 2, 0);
        gh.put(3, 3, 1);

        filter1.transition_matrix(gh);
        CvMat measurement = CvMat.create(2, 1);

        CvMat stateMat = CvMat.create(4, 1);
        stateMat.put(0, 0, point.x());
        stateMat.put(1, 0, point.y());
        stateMat.put(2, 0, 0);
        stateMat.put(3, 0, 0);

        filter1.state_pre(stateMat);
        filter1.MeasurementMatr(null);
        filter1.process_noise_cov(CvMat.create(1, 1).put(0, 0, 1e-4));
        filter1.measurement_noise_cov(CvMat.create(1, 1).put(0, 0, 1e-1));
        filter1.error_cov_post(CvMat.create(1, 1).put(0, 0, 0.1));

        CvMat prediction = opencv_video.cvKalmanPredict(filter1, null);
        opencv_video.cvKalmanCorrect(filter1, null);
        CvPoint predictPt = new CvPoint();
        predictPt.put(0, 1);
        measurement.put(0, 1, point.x());
        measurement.put(0, 2, point.y());






    }
/// First predict, to update the internal statePre variable
//Mat prediction = KF.predict();
//Point predictPt(prediction.at<float>(0),prediction.at<float>(1));
//
//// Get mouse point
//measurement(0) = mouse_info.x;
//measurement(1) = mouse_info.y;
//
//Point measPt(measurement(0),measurement(1));
//
//// The "correct" phase that is going to use the predicted value and our measurement
//Mat estimated = KF.correct(measurement);
//Point statePt(estimated.at<float>(0),estimated.at<float>(1));
}
